//
//  Player_imageView.m
//  SoundPill
//
//  Created by 宋旭东 on 15/4/15.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "Player_imageView.h"

@interface Player_imageView ()

@end

@implementation Player_imageView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *BWB =[[UIImageView alloc] initWithFrame:self.bounds];
        BWB.image = [UIImage imageNamed:@"Play_BWB"];
        [self setContentScaleFactor:[[UIScreen mainScreen] scale]];
        self.contentMode =  UIViewContentModeScaleAspectFill;
        self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
        self.clipsToBounds  = YES;

        [self addSubview:BWB];
        [self createShowLabel];
    }
    return self;
}
- (void)createShowLabel
{
    self.labelBackground = [[UIView alloc] initWithFrame:CGRectZero];
    _labelBackground.hidden = YES;
    _labelBackground.backgroundColor = [UIColor blackColor];
    [self addSubview:_labelBackground];
    self.showView = [[UILabel alloc] initWithFrame:CGRectZero];
    _showView.textAlignment = NSTextAlignmentLeft;
    _showView.backgroundColor = [UIColor blackColor];
    _showView.lineBreakMode = NSLineBreakByWordWrapping;
    _showView.numberOfLines = 0;
    _showView.textColor = [UIColor whiteColor];
    [_labelBackground addSubview:_showView];
}

- (void)setLabelText:(NSString *)text{
    UIFont *font = [UIFont fontWithName:@"Arial" size:16];
    _showView.font = font;
    _showView.text = text;
    CGSize deSize = [_showView sizeThatFits:CGSizeMake([UIScreen mainScreen].bounds.size.width * 0.423,CGFLOAT_MAX)];
    _labelBackground.frame = CGRectMake(0, self.bounds.origin.y + self.bounds.size.height - deSize.height - 20, deSize.width + 20, deSize.height + 5);
    _showView.frame = CGRectMake(10, 0, deSize.width, deSize.height + 5);
}
@end
